import http from '@/http/api'
import { UserTagDef } from "@/variables/uploadDefaultTags";

const state = {
    userTagList: [],
    userFacilityList: [],
    uploadTypeId: '',
    uploadLocationInfo: null
}
const mutations = {
    SET_USER_TAG_LIST(state, newTags) {
        state.userTagList = UserTagDef
    },
    SET_FACILITY_LIST(state, newFacility) {
        state.userFacilityList = newFacility
    }
}
const actions = {
    GetUserTagList({ commit, rootState }) {
        return new Promise(async (resolve, reject) => {
            const { retCode, data } = await http.getTagList({ wxOpenId: rootState.user.openid }, false)
            if (retCode === 0) {
                commit('SET_USER_TAG_LIST', data)
            }
            resolve()
        })
    },
    GetFacilityList({ commit, rootState }) {
        return new Promise(async (resolve, reject) => {
            const { retCode, data } = await http.getCategoryList({ action: 'wxUserGetAccessibilityFacilityCategoryList', wxOpenId: rootState.user.openid }, false)
            if (retCode === 0) {
                commit('SET_FACILITY_LIST', data)
            }
            resolve()
        })
    },
}



export default {
    namespaced: true,
    state,
    mutations,
    actions
}